/*
 * Copyright (c) 2013 XDream
 * Copyright (c) 2013 bruceshu <shuhuan.bruce@gmail.com>
 * 2024-9-20
 */

#ifndef VIDEO_DECODER_H
#define VIDEO_DECODER_H


#include <string>

#include <mutex>
#include <map>

#ifdef __cplusplus
extern "C" {
#endif

#include "libavutil/frame.h"

#ifdef __cplusplus
}
#endif

#include "video_common_define.h"
#include "AVBuffer.h"

namespace mydecoder {

class VideoDecodedCallback
{
public:
    virtual VideoCodecError on_decoded_error() = 0;
    virtual ~VideoDecodedCallback() = default;
    virtual VideoCodecError onDecodedFrame(AVFrame *frame);
};


class VideoDecoder
{
private:
    std::mutex m_optionMutex;
    std::map<std::string, std::string> m_options;
public:
    VideoDecoder(/* args */);
    virtual ~VideoDecoder();
    virtual VideoCodecError init(const AVBuffer *buffer) = 0;
    virtual VideoCodecError decode() = 0;
    virtual void flush() = 0;
    virtual void registerDecodedCallback(VideoDecodedCallback *callback);
    virtual void setOption(std::string key, std::string value);
    virtual std::string getOption(std::string key);
    // virtual VideoCodecError set_video_format_description(const Buffer* buffer) = 0;

    // virtual VideoCodecError get_delayed_frame() = 0;
    // virtual VideoCodecError set_hardware_context(HardwareContext *context) = 0;
    // virtual VideoCodecError set_skip_frame(int skip_frame) = 0;

public:
    VideoDecodedCallback *m_videoDecodedCallback;
};




}



#endif